//
//  dCurveView.h
//  Accuro Care
//
//  Created by Yongfeng Li on 6/30/14.
//  Copyright (c) 2014 Yongfeng Li. All rights reserved.
//

#import <UIKit/UIKit.h>

@class UICurveView;

typedef enum
{
    GraphViewXLabelTypeVerticle,	// X-Axis labels will be rotated 90 degrees counter-clockwise
    GraphViewXLabelTypeHorizontal, // X-Axis labels are horizontal (watch out that they don't over-lap! You can adjust the font through properties defined in this class)
    GraphViewXLabelTypeAngled		// X-Axis labels are rotated 45 degrees counter-clockwise
} GraphViewXLabelType;

@protocol CurveViewDataSource <NSObject>

@required

- (NSUInteger)numberOfBarsInBarChart:(UICurveView *)barChart;
- (CGFloat)barChart:(UICurveView *)barChart valueForBarAtIndex:(NSUInteger)index;
- (CGFloat)barChart:(UICurveView *)barChart xposForBarAtIndex:(NSUInteger)index;

- (NSString *)barChart:(UICurveView *)barChart xLabelForBarAtIndex:(NSUInteger)index;
- (NSString *)barChart:(UICurveView *)barChart textForBarAtIndex:(NSUInteger)index;
- (UIColor *)barChart:(UICurveView *)barChart colorForBarAtIndex:(NSUInteger)index;

@optional

- (UIColor *)barChartColor:(NSInteger)nIdx;
- (short)barChart:(UICurveView *)barChart hRateForBarAtIndex:(NSUInteger)index;

- (int) totalRcvedCount;
- (double) HrateTimeInterval;

@end

@protocol CurveViewDelegate <NSObject>

@optional

- (void)animationDidEndForBarChart:(UICurveView *)barChart;

@end

@interface UICurveView : UIView

@property (weak, nonatomic) id <CurveViewDataSource> dataSource;
@property (weak, nonatomic) id <CurveViewDelegate> delegate;

@property (nonatomic, readonly, strong) NSMutableArray *values;

@property (nonatomic, strong) UIFont *xLabelFont;
@property (nonatomic, strong) UIColor *xLabelColor;
@property (nonatomic, assign) GraphViewXLabelType xLabelType;

@property (nonatomic, assign) BOOL hasYLabels;
@property (nonatomic, strong) UIFont *yLabelFont;
@property (nonatomic, strong) UIColor *yLabelColor;


@property (nonatomic, assign) BOOL hasGrids;
@property (nonatomic, strong) UIColor *gridColor;
@property (nonatomic, assign) NSInteger incrementValue;
@property (nonatomic, assign) NSInteger incrmtxposValue;

@property (nonatomic, assign) CGFloat m_yMin;
@property (nonatomic, assign) CGFloat m_yMax;
@property (nonatomic, assign) CGFloat m_fMaxDurVal;

@property (nonatomic, assign) CGFloat animationDuration; // How long the entire drawing will take
//@property (nonatomic, assign) UIColor *chartBorderColor;

@property (nonatomic, assign) CGFloat barWidth;
@property (nonatomic, assign) BOOL bViewDataRcd;


- (id)initWithFrame:(CGRect)frame hBar:(BOOL)bHorBar;

- (void) setFitnessHrates:(float)fMaxVal;
- (void) setFitnessRngBpm:(float)nMinVal maxHrt:(float)nMaxVal;

- (void) addHrmMeasVal:(short)hHrate;
- (void) updateValues:(short)hHrate;
- (void) reloadData;

- (int) getHrateRngIdx:(short)nHrate;
- (void) setTimeRngDur:(int)nIdx dur:(CGFloat)fSecDur;

- (double) showHrateItem:(NSMutableArray*)pHrateItem;
- (CGFloat) showHrateDurTime:(NSMutableArray*)pHrateItem start:(NSDate*)dtStart;
- (CGFloat*) getBandDurTime;

- (void) resetData;
- (void) hideHgtBar:(BOOL)bHide;;
@end
